package com.charger.cooperation.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.charger.common.annotation.Log;
import com.charger.common.core.controller.BaseController;
import com.charger.common.core.domain.AjaxResult;
import com.charger.common.enums.BusinessType;
import com.charger.cooperation.domain.InvestorsProjects;
import com.charger.cooperation.service.IInvestorsProjectsService;
import com.charger.common.utils.poi.ExcelUtil;
import com.charger.common.core.page.TableDataInfo;

/**
 * 中间表Controller
 * 
 * @author ruoyi
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/cooperation/investorsProjects")
public class InvestorsProjectsController extends BaseController
{
    @Autowired
    private IInvestorsProjectsService investorsProjectsService;

    /**
     * 查询中间表列表
     */
    @PreAuthorize("@ss.hasPermi('cooperation:investorsProjects:list')")
    @GetMapping("/list")
    public TableDataInfo list(InvestorsProjects investorsProjects)
    {
        startPage();
        List<InvestorsProjects> list = investorsProjectsService.selectInvestorsProjectsList(investorsProjects);
        return getDataTable(list);
    }

    /**
     * 导出中间表列表
     */
    @PreAuthorize("@ss.hasPermi('cooperation:investorsProjects:export')")
    @Log(title = "中间表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InvestorsProjects investorsProjects)
    {
        List<InvestorsProjects> list = investorsProjectsService.selectInvestorsProjectsList(investorsProjects);
        ExcelUtil<InvestorsProjects> util = new ExcelUtil<InvestorsProjects>(InvestorsProjects.class);
        util.exportExcel(response, list, "中间表数据");
    }

    /**
     * 获取中间表详细信息
     */
    @PreAuthorize("@ss.hasPermi('cooperation:investorsProjects:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(investorsProjectsService.selectInvestorsProjectsById(id));
    }

    /**
     * 新增中间表
     */
    @PreAuthorize("@ss.hasPermi('cooperation:investorsProjects:add')")
    @Log(title = "中间表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InvestorsProjects investorsProjects)
    {
        return toAjax(investorsProjectsService.insertInvestorsProjects(investorsProjects));
    }

    /**
     * 修改中间表
     */
    @PreAuthorize("@ss.hasPermi('cooperation:investorsProjects:edit')")
    @Log(title = "中间表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InvestorsProjects investorsProjects)
    {
        return toAjax(investorsProjectsService.updateInvestorsProjects(investorsProjects));
    }

    /**
     * 删除中间表
     */
    @PreAuthorize("@ss.hasPermi('cooperation:investorsProjects:remove')")
    @Log(title = "中间表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(investorsProjectsService.deleteInvestorsProjectsByIds(ids));
    }
}
